package com.example.Laboratory.Controller;

import com.example.Laboratory.Entity.Leader;
import com.example.Laboratory.Service.LeaderService;
import com.example.Laboratory.Untils.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;

@Api(value = "Leader", description = "研究队伍-学科带队人")
@RestController
@RequestMapping(value = "/Leader")
@CrossOrigin
public class LeaderController {

    @Autowired
    LeaderService leaderService;

    @ApiOperation(value = "添加学科带队人信息", notes = "添加学科带队人信息")
    @RequestMapping(value = "/addLeader", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object addLeader (Leader l) throws IOException {
        return ResultCode.SUCCESS.result(leaderService.addLeader(l));
    }

    @ApiOperation(value = "删除学科带队人信息", notes = "删除学科带队人信息")
    @RequestMapping(value = "/deleteLeader", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public Object deleteLeader (@RequestParam int leader_id) throws IOException {
        return ResultCode.SUCCESS.result(leaderService.deleteLeader(leader_id));
    }

    @ApiOperation(value = "查找学科带队人信息", notes = "查找学科带队人信息")
    @RequestMapping(value = "/researchLeader", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object researchLeader ( ) throws IOException {
        return ResultCode.SUCCESS.result(leaderService.researchLeader());
    }

    @ApiOperation(value = "修改学科带队人信息", notes = "修改学科带队人信息")
    @RequestMapping(value = "/reviseLeader", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object reviseLeader (Leader l) throws IOException {
        return ResultCode.SUCCESS.result(leaderService.reviseLeader(l));
    }
}
